<template>
  <div class="echarts">
    <div
      :style="{ width: chartWidth, height: chartHeight }"
      class="no-data"
      v-if="this.chartData.rows && this.chartData.rows.length == 0"
    >
      <span>画图展无数据</span>
    </div>
    <div ref="gauge" :style="{ width: chartWidth, height: chartHeight }"></div>
  </div>
</template>

<script>
import OptionGauge from './../echarts-js/echarts-gauge'
import echartsMixin from './../echarts-js/echarts-mixin'
export default {
  mixins: [echartsMixin],
  mounted() {
    this.initChart()
  },
  methods: {
    initChart() {
      let theme = ''
      if (this.settings.theme) {
        theme = this.settings.theme
      }
      //设置画图对象
      this.myChart = this.$echarts.init(this.$refs.gauge, theme)
      const gauge = new OptionGauge(this.chartData, this.settings, this.extend)
      this.myChart.setOption(gauge.option)
      setInterval(() => {
        gauge.option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0
        this.myChart.setOption(gauge.option)
      }, 2000)
    },
  }
}
</script>

<style>
</style>